#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""启动脚本"""

import os
import sys
import uvicorn
from dotenv import load_dotenv

# 加载环境变量
load_dotenv()

# 获取配置
HOST = os.getenv("SERVER_HOST", "127.0.0.1")
PORT = int(os.getenv("SERVER_PORT", "8080"))
DEBUG = os.getenv("DEBUG", "False").lower() in ("true", "1", "t")
RELOAD = DEBUG

def main():
    """主函数"""
    print(f"启动服务: http://{HOST}:{PORT}")
    print(f"调试模式: {DEBUG}")
    print(f"API文档: http://{HOST}:{PORT}/docs")
    
    # 启动服务
    uvicorn.run(
        "app.main:app",
        host=HOST,
        port=PORT,
        reload=RELOAD,
        log_level="debug" if DEBUG else "info"
    )

if __name__ == "__main__":
    main()